 function JimetInputLoaderObj() { 
 	this.selectId = null;
 	this.postData = null;
 	this.url = null;
 	this.required = false;
 	this.endFunc = null;
 	
  	this.init = function(selectId,url,data,required){
  		this.selectId = selectId; 	
 		this.url = appRoot + url;
 		this.postData = data;
 		this.required = required;
 	}	
 	
 	this.doLoad = function (selectId,url,data,required) {
 		this.init(selectId,url,data,required);
 		var self = this;		
		$.ajax({
			type: "POST",
			data: this.postData,
			contentType: "application/x-www-form-urlencoded; charset=utf-8",	
			url: this.url,
		  	success: function(response){
				loadSelectFunc(response , self )
		  	}
		});		
 	} 
 
 	this.setEndFunc = function(func) {
 		this.endFunc = func;
	};
	
}
  
 function loadSelectFunc ( result,self ) {
 		
	if( result==null && result.text && (result.text.length>0) && result.text=='ajaxError'){
		return;
	}

	var selectObj = document.getElementById(self.selectId);
	var y = result.getElementsByTagName("optionItem");
 		
	var grps;
	if(result.getElementsByTagName("optionGroup"))
		grps = result.getElementsByTagName("optionGroup");

	var x;
	if(result.getElementsByTagName("optionAttribute"))
		x = result.getElementsByTagName("optionAttribute");

	var a;
	if(result.getElementsByTagName("optionAttribute1"))
		a = result.getElementsByTagName("optionAttribute1");
 		
	var b;
	if(result.getElementsByTagName("optionAttribute2"))
		b = result.getElementsByTagName("optionAttribute2");
 		
	var c;
	if(result.getElementsByTagName("optionAttribute3"))
		c = result.getElementsByTagName("optionAttribute3");
 		
	var val = '';

	if(selectObj!=null&&selectObj.getAttribute('validator'))
		val = selectObj.getAttribute('validator');
 		
	var pair = val.split(';');
	if (selectObj!=null&&y.length >0)
	{
		if (selectObj.length>0)
			firstOpt = selectObj.options[0];
		
 		selectObj.options.length=0;	
 		var j = 0;
 		if (firstOpt)
 		{
 			selectObj.options[0] = new Option(firstOpt.text,firstOpt.value);
 			j++;
 		}		
 		
 		for (i=0;i<y.length;i++)
 		{
 			if(grps.item(i)!=null)
 			{
	 			var myVal=grps[i].childNodes[0].nodeValue;
	 			
	 			if(myVal!='-1')
	 			{
	 				optGrp = document.createElement('optgroup');
	 				optGrp.label = myVal;
	 				selectObj.appendChild(optGrp);
	 			}	
 			}

 			var attlist=y.item(i).attributes;
 			var att=attlist.getNamedItem("optionValue");
 			selectObj.options[i+j] = new Option(y[i].childNodes[0].nodeValue,att.value);
 			if(attlist.getNamedItem("selected")&&attlist.getNamedItem("selected").value=='selected')
 				selectObj.options[i+j].selected = 'selected';
 			
 			
 			if(x.item(i)!=null)
 			{
	 			var myAttlist=x.item(i).attributes;
	 			var myAtt=myAttlist.getNamedItem("attValue");
	 			selectObj.options[i+j].setAttribute(x[i].childNodes[0].nodeValue,myAtt.value);
 			}
 			
 			if(a.item(i)!=null)
 			{
	 			var myAttlist=a.item(i).attributes;
	 			var myAtt=myAttlist.getNamedItem("attValue1");
	 			selectObj.options[i+j].setAttribute(a[i].childNodes[0].nodeValue,myAtt.value);
	 		}	 			

 			if(b.item(i)!=null)
 			{
	 			var myAttlist=b.item(i).attributes;
	 			var myAtt=myAttlist.getNamedItem("attValue2");
	 			selectObj.options[i+j].setAttribute(b[i].childNodes[0].nodeValue,myAtt.value);
	 		}	 			

 			if(c.item(i)!=null)
 			{
	 			var myAttlist=c.item(i).attributes;
	 			var myAtt=myAttlist.getNamedItem("attValue3");
	 			selectObj.options[i+j].setAttribute(c[i].childNodes[0].nodeValue,myAtt.value);
	 		}	 			
 		}
 		

		if (this.required == true && selectObj.getAttribute('validator'))
			str1 = '1' + ';' + pair[1] + ';' + pair[2] + ';' + pair[3] + ';' + pair[4];
		else if(this.required == false && selectObj.getAttribute('validator'))
			str1 = '0' + ';' + pair[1] + ';' + pair[2] + ';' + pair[3] + ';' + pair[4];
	
 		if(selectObj.getAttribute('validator'))
 			selectObj.setAttribute('validator',str1);

	}
	else if(selectObj!=null){
  		var firstOpt = selectObj.options[0];
  		if (firstOpt)
  		{
	 		selectObj.options.length=0;	
	 		selectObj.options[0] = new Option(firstOpt.text,firstOpt.value);		
	 		selectObj.disabled = true;
	 		if(selectObj.getAttribute('validator'))
	 			str1 = '0' + ';' + pair[1] + ';' + pair[2] + ';' + pair[3] + ';' + pair[4];
	 		
	 		if(selectObj.getAttribute('validator'))
	 			selectObj.setAttribute('validator',str1);

	 	}
	}
 } 